﻿Imports Utilidades
Imports Excepciones
Imports Negocio
Imports Servicios
Imports System.IO

Public Class frmABMRecurso

    Private _recurso As New Recurso()

    Protected Overrides Sub PreLoad()
        Me.Icon = Icon.FromHandle(Global.SIPRO.My.Resources.Resources.Person.GetHicon())
    End Sub

    Sub New()
        InitializeComponent()
    End Sub
    Sub New(recurso As Recurso)
        Me.New()
        _recurso = recurso
        btnGuardar.Tag = "Modificar"
    End Sub

    Private Sub frmABMRecurso_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        txtNombre.DataBindings.Add("Text", _recurso, "Nombre")
        txtApellido.DataBindings.Add("Text", _recurso, "Apellido")
        txtDni.DataBindings.Add("Text", _recurso, "Dni")
        txtEmail.DataBindings.Add("Text", _recurso, "Email")
    End Sub


    Private Sub OK_Click(sender As System.Object, e As System.EventArgs) Handles btnGuardar.Click
        If MyBase.ValidateForm() Then
            Try
                GesRecursos.Guardar(_recurso)
                Me.Close()
                Me.DialogResult = Windows.Forms.DialogResult.OK
            Catch ex As Exception
                My.Application.HandlerException(New ResourceSaveException())
            End Try
        End If

    End Sub

    Private Sub Cancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancelar.Click
        Me.Close()
    End Sub


End Class